using System;
using System.Collections.Generic;
using System.Text;

namespace My.IdlConverter.Core.Rules
{
    public class NotContainRule : IRule
    {
        public virtual IEnumerable<TElement> DoIt<TElement, TCondition>(IEnumerable<TElement> elements, IEnumerable<TCondition> conditions)
        {
            if ((elements == null) || (conditions == null))
                return elements;

            List<TElement> yieldElements = new List<TElement>();
            foreach (TElement nextElement in elements)
            {
                yieldElements.Add(nextElement);

                string element = nextElement as string;
                foreach (TCondition nextCondition in conditions)
                {
                    string pattern = nextCondition as string;
                    if (element.Contains(pattern))
                    {
                        yieldElements.Remove(nextElement);
                        break;
                    }
                }
            }

            return yieldElements;
        }
    }
}
